//Page 353
//Convert an ordinary binary function pow(...) to an adaptable
//function object using ptr_fun(...). Note: pow(...) is a overloaded
//function. We need tell compiler which one to use using explicit 
//function template specialization.

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>

using namespace std ;

double d[] = { 1.23, 91.37, 56.661, 23.23, 19.959, 1.0, 3.14159 } ;
const int DSZ = sizeof d / sizeof *d ;

bool isEven ( int x ) { return x % 2 == 0 ; }

int main ( ) 
{
	vector<double> vd ;
	transform ( d, d+DSZ, back_inserter(vd), bind2nd(ptr_fun<double, double, double>(pow), 2.0)) ;
	copy(vd.begin(), vd.end(), ostream_iterator<double>(cout, " "));
	
	cout << endl ;

	return 0 ;
}
